package chapter6.No6_1_立即加载_饿汉模式.demo7;

/**
 * Created by Administrator on 2016/11/25.
 */
public class MyObject {
    private static MyObject object;

    private MyObject() {
    }

    public static MyObject getInstance() {
        if (object == null) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (MyObject.class) {
                if(object == null) {
                    object = new MyObject();
                }
            }
        }
        return object;
    }
}
